﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BusinessClass.StateMachine.Core
{
    public class ParallelStates<TstateReturn> : ISate<IEnumerable<TstateReturn>>
    {
        public ISate<TstateReturn>[] States { get; private set; }
        public ParallelStates(ISate<TstateReturn>[] states)
        {
            States = states;
        }
        public IEnumerable<TstateReturn> Accept(Machine m)
        {
            var ret = from state in States.AsParallel()
                      select m.Visit(state);
            return ret.ToArray();
        }
    }
}
